package com.seal.tsms.exam.controller;

import com.seal.tsms.base.controller.BaseController;
import com.seal.tsms.base.service.BaseService;
import com.seal.tsms.exam.entity.Chapter;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by lenovo on 2016/6/6.
 */
@Controller
@RequestMapping("/chapter")
public class ChapterController extends BaseController<Chapter,String> {
    @Override
    @Autowired
    @Qualifier("chapterServiceImpl")
    public void setSelfService(BaseService<Chapter, String> selfService) {
        super.setSelfService(selfService);
    }
@RequestMapping(value = "/save",method = RequestMethod.GET)
public String create(){
    return "exam/Chapter/add";
}
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public String save(Chapter chapter){
        getSelfService().save(chapter);
        return "ok";
    }
    @RequestMapping(value = "chapterListAjax")
    @ResponseBody
    public List<Chapter> ajaxList(){
        return  (List<Chapter>) getSelfService().list(DetachedCriteria.forClass(Chapter.class),null);

    }
}
